package com.sinosoft.system.primary.biz.imp;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sinosoft.system.primary.biz.SysMenuBiz;
import com.sinosoft.system.primary.dao.SysMenuDao;
import com.sinosoft.system.primary.entity.SysMenu;
import com.sinosoft.system.util.page.Pagenation;

@Service
@Transactional
public class SysMenuBizImp implements SysMenuBiz{

	private static Logger log = Logger.getLogger(SysMenuBizImp.class);
	
	@Autowired
	private SysMenuDao sysMenuDao;
	
	@Override
	public int insertSysMenu(SysMenu sysMenu) {
		log.info("新增SysMenu数据"+sysMenu.toString());
		return sysMenuDao.insertSysMenu(sysMenu);
	}

	@Override
	public int updateSysMenu(SysMenu sysMenu) {
		log.info("更新SysMenu数据"+sysMenu.toString());
		return sysMenuDao.updateSysMenu(sysMenu);
	}

	@Override
	public int deleteSysMenu(int id) {
		log.info("删除SysMenu数据 id="+id);
		return sysMenuDao.deleteSysMenu(id);
	}

	@Override
	public SysMenu selectSysMenu(int id) {
		log.info("根据ID查询SysMenu数据 id="+id);
		return sysMenuDao.selectSysMenu(id);
	}

	@Override
	public SysMenu selectSysMenu(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysMenu数据 ");
		return sysMenuDao.selectSysMenu(queryKeys, queryValues);
	}

	@Override
	public int selectCountSysMenu() {
		log.info("查询SysMenu数据 总数量");
		return sysMenuDao.selectCountSysMenu();
	}

	@Override
	public int selectCountSysMenu(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysMenu数据 总数量"+queryKeys.toString());
		return sysMenuDao.selectCountSysMenu(queryKeys, queryValues);
	}

	@Override
	public List<SysMenu> selectLimitSysMenu(int start, int size) {
		log.info("查询SysMenu数据 limit数量:start="+start+",size="+size);
		return sysMenuDao.selectLimitSysMenu(start, size);
	}

	@Override
	public List<SysMenu> selectLimitSysMenu(List<String> queryKeys,List<Object> queryValues,int start, int size) {
		log.info("条件查询SysMenu数据数量");
		return sysMenuDao.selectLimitSysMenu(queryKeys, queryValues, start,  size);
	}

	@Override
	public List<SysMenu> selectAllSysMenu() {
		log.info("查询所有SysMenu数据");
		return sysMenuDao.selectAllSysMenu();
	}

	@Override
	public List<SysMenu> selectAllSysMenu(List<String> queryKeys,List<Object> queryValues) {
		log.info("条件查询所有SysMenu数据");
		return sysMenuDao.selectAllSysMenu(queryKeys, queryValues);
	}

	@Override
	public Pagenation selectPageSysMenu(Pagenation page) {
		log.info("分页查询所有SysMenu数据");
		int start =	page.getStartRow();
		int size = page.getPageSize();
		List<SysMenu> rows = sysMenuDao.selectLimitSysMenu(page.getQueryKeys(), page.getQueryValues(),start,size);
		int total = sysMenuDao.selectCountSysMenu(page.getQueryKeys(), page.getQueryValues());
		page.setTotal(total);
		page.setRows(rows);
		return page;
	}
	
	@Override
	public boolean isPermitted(String roleids,String uri) {
		log.info("是否允许访问SysMenu数据");
		return sysMenuDao.isPermitted(roleids, uri);
	}

	public SysMenuDao getSysMenuDao() {
		return sysMenuDao;
	}

	public void setSysMenuDao(SysMenuDao sysMenuDao) {
		this.sysMenuDao = sysMenuDao;
	}



}
